package com.mf.service.impl;

import com.mf.entity.CanPurchaseDm;
import com.mf.mapper.CanPurchaseDmMapper;

import com.mf.service.ICanPurchaseDmService;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
* <p>
    * 可购买代码 服务实现类
    * </p>
*
* @author mf
* @since 2024-06-08
*/
@Service
public class CanPurchaseDmServiceImpl extends ServiceImpl<CanPurchaseDmMapper, CanPurchaseDm> implements ICanPurchaseDmService {
    @Resource
    private CanPurchaseDmMapper canPurchaseDmMapper;

    /**
     * 删除原来计算代码  并返回新的计算代码集合
     * @param code 新代码集合 (没有组装前)
     * @return 新代码集合
     */
    @Override
    public List<CanPurchaseDm> getSaveBatchCodeList(List<String> code) {
        canPurchaseDmMapper.delete(null);
        List<CanPurchaseDm> canPurchaseDm = new ArrayList<>();
        for (String c : code) {
            final CanPurchaseDm purchaseDm = new CanPurchaseDm();
            purchaseDm.setDm(c);
            canPurchaseDm.add(purchaseDm);
        }
        return canPurchaseDm;
    }
}
